package main;
import java.io.IOException;
import java.util.LinkedList;
import java.util.List;

import commands.Comando;
import commands.CreateTablesCommand;
import commands.DropTablesCommand;
import commands.ListCommentsCommand;
import commands.PostCommentCommand;
import commands.PostPhotoCommand;
import commands.PostUserCommand;
import commands.PostVoteCommand;
import commands.RemoveCommentCommand;
import commands.RemoveCommentsWithoutPhotosCommand;
import commands.RemovePhotoCommand;
import commands.RemovePhotosWithoutUsersCommand;
import commands.RemoveUserCommand;
import commands.RemoveVoteCommand;
import commands.RemoveVotesWithoutCommentsCommand;
import commands.TopTenCommentsCommand;
import commands.TopTenPhotosCommand;
import commands.TopTrendsWordsCommand;

public class Executor {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		if (args.length == 0) {
			printSintaxe();
			System.exit(1);
		}
		
		executarComando(args);
	}
	
	private static void executarComando(String[] args) throws IOException{
		List<Comando> commands = new LinkedList<Comando>();
		commands.add(new CreateTablesCommand());
		commands.add(new DropTablesCommand());
		commands.add(new PostUserCommand());
		commands.add(new PostPhotoCommand());
		commands.add(new PostVoteCommand());
		commands.add(new PostCommentCommand());
		commands.add(new RemoveUserCommand());	
		commands.add(new RemovePhotoCommand());
		commands.add(new RemoveCommentCommand());
		commands.add(new RemoveVoteCommand());
		commands.add(new TopTrendsWordsCommand());
		commands.add(new TopTenCommentsCommand());
		commands.add(new ListCommentsCommand());
		commands.add(new TopTenPhotosCommand());
		commands.add(new RemoveCommentsWithoutPhotosCommand());
		commands.add(new RemovePhotosWithoutUsersCommand());
		commands.add(new RemoveVotesWithoutCommentsCommand());
		
		for(Comando cmd: commands ){
			if(cmd.getKey().equals(args[0])){
				System.out.println(cmd.execute(args));
			}
		}
	}

	private static void printSintaxe() {
		System.err.print("---------");
	}

}
